<?php
/**
 * 注释不留名,代码随便用
 * Date: 2019/7/19
 * Time: 11:24
 */
namespace behavior;
use think\Db;

/**
 * 向系统发送消息
 * Class SystemMessage
 */
class SystemMessage
{
    public function run(array $param){
        if(empty(@$param['title'])){
            return '缺少内部参数title';
        }
        if(empty(@$param['desc'])){
            return '缺少内部参数desc';
        }
        return Db::name('system_message')->insert([
            'code'  => @$param['code'] ? : date('md') . rand(1000,9999),
            'title' => $param['title'],
            'type'  => @$param['type'] ? :'info',
            'url'   => @$param['url'] ? : '',
            'desc'  => $param['desc'],
            'create_at' => date('Y-m-d H:i:s')
        ]);
    }
}